<%@ page language="java" pageEncoding="utf-8" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>演职人员资料列表</title>
    <jsp:include page="/IncludeJS.jsp"></jsp:include>
</head>
<body>
<script type="text/javascript">
    $(function () {
        var pager = $(".easyui-datagrid").datagrid('getPager');
        $(pager).pagination({
            total:${pager.totalRows},
            pageSize:${pager.pageRow},
            displayMsg: '{from}-{to}/{total}',
            pageNumber:${pager.cur_page},
            afterPageText: '页，共{pages}页',
            pageList: [100, 500, 1000, 10000],
            loading: false,
            showPageList: true,
            showRefresh: true,
            //刷新方法
            onBeforeRefresh: function (p, s) {
                location.href = "${pageContext.request.contextPath }/movieActor/list?movieId=${movieId}&cur_page=" + p + "&pageRow=" + s;
            },
            onSelectPage: function (p, s) {
                location.href = "${pageContext.request.contextPath }/movieActor/list?movieId=${movieId}&cur_page=" + p + "&pageRow=" + s;
            }
        });
        $('#changesize').datagrid('resize', {
            height: document.body.clientHeight - 45
        });
    });

    function edit() {
        var ids = $('input[name="id"]:checked');
        var len = ids.length;
        if (ids.length == 0) {
            alert("请选择要修改的演职人员");
            return;
        }
        if (ids.length > 1) {
            alert("只能选择一位演职人员");
            return;
        }
        var arr = "";
        ids.each(function (i, d) {
            if ((i + 1) != len) {
                arr += $(d).val() + ",";
            } else {
                arr += $(d).val();
            }
        })
        url = "${pageContext.request.contextPath }/movieActor/update?movieId=" + arr;
        location.href = url;
    }

    function getRowData(value, rec) {
        var id = rec.id;
    }

    function save() {
        document.forms[1].submit();
    }

    function add() {
        var url = "${pageContext.request.contextPath }/movieActor/add";
        // var title="区域新增";
        // addTab1(title, url);
        location.href = url;
    }

    function del() {
        var ids = $('input[name="id"]:checked');
        var len = ids.length;
        if (ids.length == 0) {
            alert("请选择要删除的演职人员");
            return;
        }
        if (!confirm('删除演职人确认')) {
            return;
        }
        var arr = "";
        ids.each(function (i, d) {
            if ((i + 1) != len) {
                arr += $(d).val() + ",";
            } else {
                arr += $(d).val();
            }
        })
        var url = "${pageContext.request.contextPath }/movieActor/del?ids=" + arr;
        location.href = url;
    }

    if ("${msg}" != null && "${msg}".length > 0) {
        alert("${msg}");
    }
</script>
<table width="100%" border="0" cellpadding="0" cellspacing="0"
       BACKGROUND="${pageContext.request.contextPath }/images/maintitle.jpg" class="tablelist2">
    <form action="${pageContext.request.contextPath }/movieActor/save" method="post">
        <input type="hidden" name="movieActorId" id="movieActorId" value="${movieActor.movieActorId}">
        <tr class="tableselect2">
            <td align="left">
                <div class="tools">
                    <ul class="toolbar">
                        <li><a href="javascript:void(0);" onclick="del();"><span><img
                                src="${pageContext.request.contextPath }/images/delete.png"></span>删除</a></li>
                    </ul>
                </div>
            </td>
            <td align="right">
                演员
                <select name="actorId" id="actorId" style="width:250px">
                    <c:forEach items="${actorList}" var="v">
                        <c:if test="${movieActor.actorId==v.actorId}">
                            <option value="${v.actorId}" selected>${v.actorName}</option>
                        </c:if>
                        <c:if test="${movieActor.actorId!=v.actorId}">
                            <option value="${v.actorId}">${v.actorName}</option>
                        </c:if>
                    </c:forEach>
                </select>
                类别
                <select name="actorType" id="actorType" style="width:250px">
                    <option value="1" <c:if test="${movieActor.actorType==1}">selected</c:if>>导演</option>
                    <option value="2" <c:if test="${movieActor.actorType==2}">selected</c:if>>演员</option>
                    <option value="3" <c:if test="${movieActor.actorType==3}">selected</c:if>>副导演</option>
                    <option value="4" <c:if test="${movieActor.actorType==4}">selected</c:if>>编剧</option>
                    <option value="5" <c:if test="${movieActor.actorType==5}">selected</c:if>>制片人</option>
                    <option value="6" <c:if test="${movieActor.actorType==6}">selected</c:if>>监制</option>
                    <option value="7" <c:if test="${movieActor.actorType==7}">selected</c:if>>音乐</option>
                    <option value="8" <c:if test="${movieActor.actorType==8}">selected</c:if>>摄影师</option>
                    <option value="9" <c:if test="${movieActor.actorType==9}">selected</c:if>>剪辑师</option>
                    <option value="10" <c:if test="${movieActor.actorType==10}">selected</c:if>>艺术指导</option>
                </select>
                <input type="submit" value="保存">
            </td>
        </tr>
    </form>
</table>
<table class="easyui-datagrid" pagination="true" id="changesize" style="width:auto;padding:0px" singleSelect="false"
       data-options="onClickRow:getRowData">
    <thead>
    <tr>
        <th field="id" checkbox="true" width=50>选择</th>
        <th field="movieName" width=200 align="center">电影名称</th>
        <th field="actorName" width=200 align="center">演职人员</th>
        <th field="actorType" width=200 align="center">角色</th>
        <th field="cimg" width=100 align="center">图片</th>
    </tr>
    </thead>
    <tbody>
    <c:forEach items="${pager.data}" var="v">
        <tr>
            <td>${v.movieActorId }</td>
            <td>${v.movieName }</td>
            <td>${v.actorName }</td>
            <td>${v.actorTypeName }</td>
            <td><img src="${pageContext.request.contextPath }/${v.cimg }" height="50"></td>
        </tr>
    </c:forEach>
    </tbody>
</table>
</body>
</html>